import axios from "axios";
import { Message } from "element-ui";
/* 用于token验证 */
// import store from "../store";
const instance = axios.create({
  baseURL: "http://localhost:8963",
  timeout: 5000,
});

instance.interceptors.request.use(
  (config) => {
    return config;
  },
  (err) => {
    console.log(err);
  }
);

instance.interceptors.response.use((response) => {
  const res = response.data;
  if (res.code !== 20000) {
    Message({
      message: res.message,
      type: "error",
      duration: 5 * 1000,
    });
    return Promise.reject("error");
  } else {
    return response.data;
  }
});

export default instance;
